//排序子序列
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n =0;
    cin >> n;
    vector<int> v;
    v.resize(n+1);

    v[n] = 0;
    for(int i =0; i<n;i++){
        cin >> v[i];
    }

    int count =0;
    int i =0;
    while(i < n){
        if(v[i] < v[i+1]){
            while(i < n && v[i] <= v[i+1]){
                i++;
            }
            i++;
            count++;
        }else if(v[i] > v[i+1]){
            while(i < n && v[i] >= v[i+1]){
                i++;
            }
            i++;
            count++;
        }else {
        i++;
        }
    }

    cout << count<< endl;

    
    return 0;
}

//牛客 字符串中找出连续最长的数字串
#include <iostream>
#include <string>
using namespace std;

int main() {
    string str, res, cur;
    cin >> str;
    for (int i = 0; i <= str.length(); i++) {
        if (str[i] >= '0' && str[i] <= '9') {
            cur += str[i];
        } else {
            if (res.size() < cur.size()) {
                res = cur;
            } else {
                cur.clear();
            }
        }
    }

    cout << res;
    return 0;
}
